<template>
    <div>
      <city-header></city-header>
      <city-search :list="cities"></city-search>
      <city-list :list="cities" :hot="hotCities" :letter="letter"></city-list>
      <alphabet :list="cities" @change="letterChange"></alphabet>
    </div>
</template>

<script>
import axios from 'axios'
import CityHeader from "./components/header";
import CitySearch from "./components/search";
import CityList from "./components/list";
import Alphabet from "./components/alphabet"
export default {
  name: "City",
  data(){
    return {
      cities:{},
      hotCities:[],
      letter:''
    }
  },
  components: {
    CityHeader,
    CitySearch,
    CityList,
    Alphabet
  },
  mounted() {
    this.getCityInfo()
  },
  methods:{
    getCityInfo(){
      axios.get('/api/city.json')
      .then(this.handleGetCityInfoSucc)
    },
    handleGetCityInfoSucc(res){
      var res=res.data
      if(res.ret && res.data){
        const data=res.data
        this.cities=data.cities
        this.hotCities=data.hotCities
        console.log(data)
      }
    },
    letterChange(letter){
      this.letter=letter
    }
  }
};
</script>

<style lang="stylus" scoped>

</style>
